package com.scnu.edu.common;

// 推荐：将 Result 提取为独立类（更规范）
// 若需保持内部类，需确保作用域正确
public class Result {
    private int code;
    private String message;
    private Object data;

    // 成功响应
    public static Result success(Object data) {
        Result r = new Result();
        r.code = 200;
        r.message = "成功";
        r.data = data;
        return r;
    }

    // 错误响应
    public static Result error(String message) {
        Result r = new Result();
        r.code = 500;
        r.message = message;
        r.data = null;
        return r;
    }

    // Getter & Setter（必须添加，否则 JSON 序列化异常）
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}